import { Draw } from "../../../Draw/Draw";

/** 拖拽结束 - 更新视图 */
export function imageBoxDragEnd(e: DragEvent, draw: Draw) {
  const thumbItem = <HTMLDivElement>e.target;
  thumbItem.classList.remove("thumb-draging");
  // 完成之后 更新 layerManager 的 layerList
  const root = draw.getRootBox();
  const thumbBox = root.querySelector(".konva-root-container-thumb")!;
  const order = [];
  for (let i = 0; i < thumbBox.children.length; i++) {
    const item = <HTMLDivElement>thumbBox.children[i];
    order.push(parseInt(item.dataset.index!));
  }
  draw.getLayerManager().updateLayerList(order);
}
